<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>BadgerDB: badgerdb::BufMgr Class Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">BadgerDB
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Friends</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="namespacebadgerdb.html">badgerdb</a>      </li>
      <li class="navelem"><a class="el" href="classbadgerdb_1_1_buf_mgr.html">BufMgr</a>      </li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-attribs">Public Attributes</a>  </div>
  <div class="headertitle">
<div class="title">badgerdb::BufMgr Class Reference</div>  </div>
</div><!--header-->
<div class="contents">
<!-- doxytag: class="badgerdb::BufMgr" -->
<p>The central class which manages the buffer pool including frame allocation and deallocation to pages in the file.  
 <a href="classbadgerdb_1_1_buf_mgr.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="buffer_8h_source.html">buffer.h</a>&gt;</code></p>

<p><a href="classbadgerdb_1_1_buf_mgr-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_buf_mgr.html#a18b7cf23b619c7c0e593d1dc45da77b4">BufMgr</a> (std::uint32_t bufs)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_buf_mgr.html#aab08001e1be18bfbd4af9113e91cf953">~BufMgr</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_buf_mgr.html#a9f853f0f1d4628e7e14374d0c7c6a4f3">readPage</a> (<a class="el" href="classbadgerdb_1_1_file.html">File</a> *file, const <a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> PageNo, <a class="el" href="classbadgerdb_1_1_page.html">Page</a> *&amp;page)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_buf_mgr.html#aa9bdf04c8543f59744db22efa9420c89">unPinPage</a> (<a class="el" href="classbadgerdb_1_1_file.html">File</a> *file, const <a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> PageNo, const bool dirty)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_buf_mgr.html#ab9ae3b12aac55b119b5763e3de2a4d2b">allocPage</a> (<a class="el" href="classbadgerdb_1_1_file.html">File</a> *file, <a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> &amp;PageNo, <a class="el" href="classbadgerdb_1_1_page.html">Page</a> *&amp;page)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_buf_mgr.html#acc61d1985720411ebb76e70f702827d3">flushFile</a> (const <a class="el" href="classbadgerdb_1_1_file.html">File</a> *file)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_buf_mgr.html#a870a80a0f0abcf3b640b913b46b64486">disposePage</a> (<a class="el" href="classbadgerdb_1_1_file.html">File</a> *file, const <a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> PageNo)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_buf_mgr.html#a598b3112b8193af603f5bc97c478a671">printSelf</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="structbadgerdb_1_1_buf_stats.html">BufStats</a> &amp;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_buf_mgr.html#a93148e1af99f06f4f264d948920b7c1c">getBufStats</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_buf_mgr.html#a702a264ae946b334414e51700edd81a0">clearBufStats</a> ()</td></tr>
<tr><td colspan="2"><h2><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="el" href="classbadgerdb_1_1_page.html">Page</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classbadgerdb_1_1_buf_mgr.html#aa498047fc351652d0bc7eabf6cb62ab0">bufPool</a></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>The central class which manages the buffer pool including frame allocation and deallocation to pages in the file. </p>

<p>Definition at line <a class="el" href="buffer_8h_source.html#l00160">160</a> of file <a class="el" href="buffer_8h_source.html">buffer.h</a>.</p>
</div><hr/><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a18b7cf23b619c7c0e593d1dc45da77b4"></a><!-- doxytag: member="badgerdb::BufMgr::BufMgr" ref="a18b7cf23b619c7c0e593d1dc45da77b4" args="(std::uint32_t bufs)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classbadgerdb_1_1_buf_mgr.html#a18b7cf23b619c7c0e593d1dc45da77b4">badgerdb::BufMgr::BufMgr</a> </td>
          <td>(</td>
          <td class="paramtype">std::uint32_t&#160;</td>
          <td class="paramname"><em>bufs</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Constructor of <a class="el" href="classbadgerdb_1_1_buf_mgr.html" title="The central class which manages the buffer pool including frame allocation and deallocation to pages ...">BufMgr</a> class </p>

<p>Definition at line <a class="el" href="buffer_8cpp_source.html#l00019">19</a> of file <a class="el" href="buffer_8cpp_source.html">buffer.cpp</a>.</p>
<div class="fragment"><pre class="fragment">  : numBufs(bufs) {
  bufDescTable = <span class="keyword">new</span> BufDesc[bufs];

  <span class="keywordflow">for</span> (<a class="code" href="namespacebadgerdb.html#a1e7378fbefaea050a47e6cde929e9c01" title="Identifier for a frame in buffer pool.">FrameId</a> i = 0; i &lt; bufs; i++) 
  {
    bufDescTable[i].frameNo = i;
    bufDescTable[i].valid = <span class="keyword">false</span>;
  }

  <a class="code" href="classbadgerdb_1_1_buf_mgr.html#aa498047fc351652d0bc7eabf6cb62ab0">bufPool</a> = <span class="keyword">new</span> Page[bufs];

  <span class="keywordtype">int</span> htsize = ((((int) (bufs * 1.2))*2)/2)+1;
  hashTable = <span class="keyword">new</span> BufHashTbl (htsize);  <span class="comment">// allocate the buffer hash table</span>

  clockHand = bufs - 1;
}
</pre></div>
</div>
</div>
<a class="anchor" id="aab08001e1be18bfbd4af9113e91cf953"></a><!-- doxytag: member="badgerdb::BufMgr::~BufMgr" ref="aab08001e1be18bfbd4af9113e91cf953" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classbadgerdb_1_1_buf_mgr.html#aab08001e1be18bfbd4af9113e91cf953">badgerdb::BufMgr::~BufMgr</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Destructor of <a class="el" href="classbadgerdb_1_1_buf_mgr.html" title="The central class which manages the buffer pool including frame allocation and deallocation to pages ...">BufMgr</a> class </p>

<p>Definition at line <a class="el" href="buffer_8cpp_source.html#l00038">38</a> of file <a class="el" href="buffer_8cpp_source.html">buffer.cpp</a>.</p>
<div class="fragment"><pre class="fragment">                {
}
</pre></div>
</div>
</div>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="ab9ae3b12aac55b119b5763e3de2a4d2b"></a><!-- doxytag: member="badgerdb::BufMgr::allocPage" ref="ab9ae3b12aac55b119b5763e3de2a4d2b" args="(File *file, PageId &amp;PageNo, Page *&amp;page)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classbadgerdb_1_1_buf_mgr.html#ab9ae3b12aac55b119b5763e3de2a4d2b">badgerdb::BufMgr::allocPage</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classbadgerdb_1_1_file.html">File</a> *&#160;</td>
          <td class="paramname"><em>file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a> &amp;&#160;</td>
          <td class="paramname"><em>PageNo</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classbadgerdb_1_1_page.html">Page</a> *&amp;&#160;</td>
          <td class="paramname"><em>page</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Allocates a new, empty page in the file and returns the <a class="el" href="classbadgerdb_1_1_page.html" title="Class which represents a fixed-size database page containing records.">Page</a> object. The newly allocated page is also assigned a frame in the buffer pool.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td><a class="el" href="classbadgerdb_1_1_file.html" title="Class which represents a file in the filesystem containing database pages.">File</a> object </td></tr>
    <tr><td class="paramname">PageNo</td><td><a class="el" href="classbadgerdb_1_1_page.html" title="Class which represents a fixed-size database page containing records.">Page</a> number. The number assigned to the page in the file is returned via this reference. </td></tr>
    <tr><td class="paramname">page</td><td>Reference to page pointer. The newly allocated in-memory <a class="el" href="classbadgerdb_1_1_page.html" title="Class which represents a fixed-size database page containing records.">Page</a> object is returned via this reference. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="buffer_8cpp_source.html#l00064">64</a> of file <a class="el" href="buffer_8cpp_source.html">buffer.cpp</a>.</p>
<div class="fragment"><pre class="fragment">{
}
</pre></div>
</div>
</div>
<a class="anchor" id="a702a264ae946b334414e51700edd81a0"></a><!-- doxytag: member="badgerdb::BufMgr::clearBufStats" ref="a702a264ae946b334414e51700edd81a0" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classbadgerdb_1_1_buf_mgr.html#a702a264ae946b334414e51700edd81a0">badgerdb::BufMgr::clearBufStats</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Clear buffer pool usage statistics </p>

<p>Definition at line <a class="el" href="buffer_8h_source.html#l00284">284</a> of file <a class="el" href="buffer_8h_source.html">buffer.h</a>.</p>
<div class="fragment"><pre class="fragment">  {
    bufStats.<a class="code" href="structbadgerdb_1_1_buf_stats.html#a04a848e5458491fd3ea56133464cadbd">clear</a>();
  }
</pre></div>
</div>
</div>
<a class="anchor" id="a870a80a0f0abcf3b640b913b46b64486"></a><!-- doxytag: member="badgerdb::BufMgr::disposePage" ref="a870a80a0f0abcf3b640b913b46b64486" args="(File *file, const PageId PageNo)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classbadgerdb_1_1_buf_mgr.html#a870a80a0f0abcf3b640b913b46b64486">badgerdb::BufMgr::disposePage</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classbadgerdb_1_1_file.html">File</a> *&#160;</td>
          <td class="paramname"><em>file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a>&#160;</td>
          <td class="paramname"><em>PageNo</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Delete page from file and also from buffer pool if present. Since the page is entirely deleted from file, its unnecessary to see if the page is dirty.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td><a class="el" href="classbadgerdb_1_1_file.html" title="Class which represents a file in the filesystem containing database pages.">File</a> object </td></tr>
    <tr><td class="paramname">PageNo</td><td><a class="el" href="classbadgerdb_1_1_page.html" title="Class which represents a fixed-size database page containing records.">Page</a> number </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="acc61d1985720411ebb76e70f702827d3"></a><!-- doxytag: member="badgerdb::BufMgr::flushFile" ref="acc61d1985720411ebb76e70f702827d3" args="(const File *file)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classbadgerdb_1_1_buf_mgr.html#acc61d1985720411ebb76e70f702827d3">badgerdb::BufMgr::flushFile</a> </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classbadgerdb_1_1_file.html">File</a> *&#160;</td>
          <td class="paramname"><em>file</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Writes out all dirty pages of the file to disk. All the frames assigned to the file need to be unpinned from buffer pool before this function can be successfully called. Otherwise Error returned.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td><a class="el" href="classbadgerdb_1_1_file.html" title="Class which represents a file in the filesystem containing database pages.">File</a> object </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt><b>Exceptions:</b></dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classbadgerdb_1_1_page_pinned_exception.html" title="An exception that is thrown when a page which is not expected to be pinned in the buffer pool is foun...">PagePinnedException</a></td><td>If any page of the file is pinned in the buffer pool </td></tr>
    <tr><td class="paramname"><a class="el" href="classbadgerdb_1_1_bad_buffer_exception.html" title="An exception that is thrown when a buffer is found whose valid is false but other variables in BufDes...">BadBufferException</a></td><td>If any frame allocated to the file is found to be invalid </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="buffer_8cpp_source.html#l00060">60</a> of file <a class="el" href="buffer_8cpp_source.html">buffer.cpp</a>.</p>
<div class="fragment"><pre class="fragment">{
}
</pre></div>
</div>
</div>
<a class="anchor" id="a93148e1af99f06f4f264d948920b7c1c"></a><!-- doxytag: member="badgerdb::BufMgr::getBufStats" ref="a93148e1af99f06f4f264d948920b7c1c" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="structbadgerdb_1_1_buf_stats.html">BufStats</a>&amp; <a class="el" href="classbadgerdb_1_1_buf_mgr.html#a93148e1af99f06f4f264d948920b7c1c">badgerdb::BufMgr::getBufStats</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [inline]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Get buffer pool usage statistics </p>

<p>Definition at line <a class="el" href="buffer_8h_source.html#l00276">276</a> of file <a class="el" href="buffer_8h_source.html">buffer.h</a>.</p>
<div class="fragment"><pre class="fragment">  {
    <span class="keywordflow">return</span> bufStats;
  }
</pre></div>
</div>
</div>
<a class="anchor" id="a598b3112b8193af603f5bc97c478a671"></a><!-- doxytag: member="badgerdb::BufMgr::printSelf" ref="a598b3112b8193af603f5bc97c478a671" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classbadgerdb_1_1_buf_mgr.html#a598b3112b8193af603f5bc97c478a671">badgerdb::BufMgr::printSelf</a> </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Print member variable values. </p>

<p>Definition at line <a class="el" href="buffer_8cpp_source.html#l00068">68</a> of file <a class="el" href="buffer_8cpp_source.html">buffer.cpp</a>.</p>
<div class="fragment"><pre class="fragment">{
  BufDesc* tmpbuf;
  <span class="keywordtype">int</span> validFrames = 0;
  
  <span class="keywordflow">for</span> (std::uint32_t i = 0; i &lt; numBufs; i++)
  {
    tmpbuf = &amp;(bufDescTable[i]);
    std::cout &lt;&lt; <span class="stringliteral">&quot;FrameNo:&quot;</span> &lt;&lt; i &lt;&lt; <span class="stringliteral">&quot; &quot;</span>;
    tmpbuf-&gt;Print();

    <span class="keywordflow">if</span> (tmpbuf-&gt;valid == <span class="keyword">true</span>)
      validFrames++;
  }

  std::cout &lt;&lt; <span class="stringliteral">&quot;Total Number of Valid Frames:&quot;</span> &lt;&lt; validFrames &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;
}
</pre></div>
</div>
</div>
<a class="anchor" id="a9f853f0f1d4628e7e14374d0c7c6a4f3"></a><!-- doxytag: member="badgerdb::BufMgr::readPage" ref="a9f853f0f1d4628e7e14374d0c7c6a4f3" args="(File *file, const PageId PageNo, Page *&amp;page)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classbadgerdb_1_1_buf_mgr.html#a9f853f0f1d4628e7e14374d0c7c6a4f3">badgerdb::BufMgr::readPage</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classbadgerdb_1_1_file.html">File</a> *&#160;</td>
          <td class="paramname"><em>file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a>&#160;</td>
          <td class="paramname"><em>PageNo</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classbadgerdb_1_1_page.html">Page</a> *&amp;&#160;</td>
          <td class="paramname"><em>page</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Reads the given page from the file into a frame and returns the pointer to page. If the requested page is already present in the buffer pool pointer to that frame is returned otherwise a new frame is allocated from the buffer pool for reading the page.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td><a class="el" href="classbadgerdb_1_1_file.html" title="Class which represents a file in the filesystem containing database pages.">File</a> object </td></tr>
    <tr><td class="paramname">PageNo</td><td><a class="el" href="classbadgerdb_1_1_page.html" title="Class which represents a fixed-size database page containing records.">Page</a> number in the file to be read </td></tr>
    <tr><td class="paramname">page</td><td>Reference to page pointer. Used to fetch the <a class="el" href="classbadgerdb_1_1_page.html" title="Class which represents a fixed-size database page containing records.">Page</a> object in which requested page from file is read in. </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="buffer_8cpp_source.html#l00051">51</a> of file <a class="el" href="buffer_8cpp_source.html">buffer.cpp</a>.</p>
<div class="fragment"><pre class="fragment">{
}
</pre></div>
</div>
</div>
<a class="anchor" id="aa9bdf04c8543f59744db22efa9420c89"></a><!-- doxytag: member="badgerdb::BufMgr::unPinPage" ref="aa9bdf04c8543f59744db22efa9420c89" args="(File *file, const PageId PageNo, const bool dirty)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classbadgerdb_1_1_buf_mgr.html#aa9bdf04c8543f59744db22efa9420c89">badgerdb::BufMgr::unPinPage</a> </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classbadgerdb_1_1_file.html">File</a> *&#160;</td>
          <td class="paramname"><em>file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="namespacebadgerdb.html#a1f49e404293bf4240756b89b53b1587a">PageId</a>&#160;</td>
          <td class="paramname"><em>PageNo</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const bool&#160;</td>
          <td class="paramname"><em>dirty</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Unpin a page from memory since it is no longer required for it to remain in memory.</p>
<dl class="params"><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramname">file</td><td><a class="el" href="classbadgerdb_1_1_file.html" title="Class which represents a file in the filesystem containing database pages.">File</a> object </td></tr>
    <tr><td class="paramname">PageNo</td><td><a class="el" href="classbadgerdb_1_1_page.html" title="Class which represents a fixed-size database page containing records.">Page</a> number </td></tr>
    <tr><td class="paramname">dirty</td><td>True if the page to be unpinned needs to be marked dirty </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt><b>Exceptions:</b></dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classbadgerdb_1_1_page_not_pinned_exception.html" title="An exception that is thrown when a page which is expected to be pinned in the buffer pool is found to...">PageNotPinnedException</a></td><td>If the page is not already pinned </td></tr>
  </table>
  </dd>
</dl>

<p>Definition at line <a class="el" href="buffer_8cpp_source.html#l00056">56</a> of file <a class="el" href="buffer_8cpp_source.html">buffer.cpp</a>.</p>
<div class="fragment"><pre class="fragment">{
}
</pre></div>
</div>
</div>
<hr/><h2>Member Data Documentation</h2>
<a class="anchor" id="aa498047fc351652d0bc7eabf6cb62ab0"></a><!-- doxytag: member="badgerdb::BufMgr::bufPool" ref="aa498047fc351652d0bc7eabf6cb62ab0" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classbadgerdb_1_1_page.html">Page</a>* <a class="el" href="classbadgerdb_1_1_buf_mgr.html#aa498047fc351652d0bc7eabf6cb62ab0">badgerdb::BufMgr::bufPool</a></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Actual buffer pool from which frames are allocated </p>

<p>Definition at line <a class="el" href="buffer_8h_source.html#l00205">205</a> of file <a class="el" href="buffer_8h_source.html">buffer.h</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>bufmgr/src/<a class="el" href="buffer_8h_source.html">buffer.h</a></li>
<li>bufmgr/src/<a class="el" href="buffer_8cpp_source.html">buffer.cpp</a></li>
</ul>
</div><!-- contents -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Friends</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Wed Jan 30 2013 14:17:57 for BadgerDB by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
